#include <GL/glut.h>      			

void init (void)
{
	glClearColor (1.0, 1.0, 1.0, 0.0);		
	glColor3f (0.0, 0.0, 1.0);			
	glMatrixMode (GL_PROJECTION);       	
	glLoadIdentity ();
	gluOrtho2D (0.0, 400.0, 0.0, 400.0);
}

void myDisplay (void)
{
	glClear (GL_COLOR_BUFFER_BIT);  
	GLubyte fillPattern [ ] = 
	{	0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0xf0, 0x0f, 0xf0, 0x0f,
		0x0f, 0xf0, 0x0f, 0xf0,
				0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
		0x0f, 0xf0, 0x0f, 0xf0,
	};
	glPolygonStipple (fillPattern);

	glEnable (GL_POLYGON_STIPPLE);
	glBegin (GL_POLYGON);			// Polygon with 4 vertices.
		glVertex2i (100, 100);		
		glVertex2i (300, 100); 		
		glVertex2i (300, 300); 		
		glVertex2i (100, 300); 		
	glEnd ( );

	glFlush ( );     
}

int main (int argc, char** argv)
{
	glutInit (&argc, argv);                         			
	glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);   	
	glutInitWindowPosition (50, 50);			
	glutInitWindowSize (400, 400);			
	glutCreateWindow ("Draw Fill-Pattern Polygon"); 

	init ( );					
	glutDisplayFunc (myDisplay);		
	glutMainLoop ( );	
    return 0;		
}
